package com.kaigejava.command.oo;

import com.kaigejava.command.sdk.LightAPI;
import com.kaigejava.command.sdk.StereoAPI;

/**
 * Created by kaigejava on 2019/8/28.
 * 传统面向对象的遥控器对象
 *
 */
public class TraditionOOControl implements Control {

    private LightAPI light;
    private StereoAPI stereo;

    public TraditionOOControl(LightAPI light,StereoAPI stereo){
        this.light = light;
        this.stereo = stereo;
    }
    @Override
    public void onButton(int slot) {
        switch (slot) {
            case 0:
                light.On();
                break;
            case 1:
                stereo.On();
                break;
            case 2:
                int vol = stereo.GetVol();
                if (vol < 11) {
                    stereo.AddVolume(++vol);
                }
                break;
        }

    }

    @Override
    public void offButton(int slot) {
        switch (slot) {
            case 0:
                light.Off();
                break;
            case 1:
                stereo.Off();
                break;
            case 2:
                int vol = stereo.GetVol();
                if (vol > 0) {
                    stereo.downVolume(--vol);
                }
                break;
        }
    }

    @Override
    public void undoButton() {

    }
}
